package week;

import java.time.temporal.WeekFields;
import java.util.*;

/**
 * @program: datastructureandalogorithm
 * @description:
 * @author: hmx
 * @create: 2022-01-08 22:18
 **/
public class Week1 {

    public int countOperations(int num1, int num2) {
        int count = 0;
        while (num1 != 0 && num2 != 0) {
            if (num1 >= num2) {
                num1 -= num2;
            } else {
                num2 -= num1;
            }
            ++count;
        }
        return count;
    }


    public int minimumSum(int num) {
        int[] nums = new int[4];
        int i = 0;
        while (num != 0) {

            nums[i++] = num % 10;
            num /= 10;
        }

        Arrays.sort(nums);
        return nums[0] * 10 + nums[2] + nums[1] * 10 + nums[3];
    }

    public int findFinalValue(int[] nums, int original) {
        Set<Integer> set = new HashSet<>();
        for (int num : nums) {
            set.add(num);
        }

        while (set.contains(original)) {
            original *= 2;
        }
        return original;
    }

    /*public static boolean checkValid(int[][] matrix) {
        int n = matrix.length;
        int[] visited = new int[n];
        for (int i = 0; i < n; i++) {
            Arrays.fill(visited, 2);
            for (int j = 0; j < n; j++) {
                int row = matrix[i][j] - 1;
                int col = matrix[j][i] - 1;
                --visited[row];
                --visited[col];
                if (visited[row] < 0) {
                    return false;
                }

                if (visited[col] < 0) {
                    return false;
                }
            }
        }

        return true;
    }

    public static void main(String[] args) {
        *//*System.out.println(capitalizeTitle("capiTalIze tHe titLe"));
        System.out.println(capitalizeTitle("L hV"));*//*

        System.out.println(checkValid(new int[][]{{1, 2, 3}, {3, 1, 2}, {2, 3, 1}}));
        System.out.println(checkValid(new int[][]{{1, 1, 1}, {1, 2, 3}, {1, 2, 3}}));
    }*/

}
